﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace LibNiconico.NiconicoApi.Lives.Broadcast
{
    /// <summary>
    /// ニコニコ生放送停止レスポンス
    /// </summary>
    public class NicoLiveBroadcastStopResponse
    {
        /// <summary>
        /// 成功したか判定
        /// </summary>
        public bool Succeed { get; private set; }

        internal NicoLiveBroadcastStopResponse(bool succeed)
        {
            this.Succeed = succeed;
        }


        internal static NicoLiveBroadcastStopResponse Parse(XDocument document)
        {
            var statusNodes = from node in document.Descendants()
                              where node.Attribute("status") != null && (string)node.Attribute("status") == "ok"
                              select node;

            return new NicoLiveBroadcastStopResponse(statusNodes.Count() > 0);

        }
    }
}
